package o;

import java.io.File;
import java.io.FileInputStream;
import java.text.DecimalFormat;

public class dfu {
    public static double ˊ(String str, int i) {
        File file = new File(str);
        long j = 0;
        try {
            if (file.isDirectory()) {
                j = ॱ(file);
            } else {
                j = ˊ(file);
            }
        } catch (Exception e) {
            Logger.e("FileSizeUtil", "getFileOrFilesSize Exception");
        }
        return ˎ(j, i);
    }

    private static long ˊ(File file) throws Exception {
        FileInputStream fileInputStream;
        Throwable th;
        long j = 0;
        if (file.exists()) {
            try {
                fileInputStream = new FileInputStream(file);
                try {
                    j = (long) fileInputStream.available();
                    if (fileInputStream != null) {
                        try {
                            fileInputStream.close();
                        } catch (Exception e) {
                            Logger.e("FileSizeUtil", "fis close error,ignore");
                        }
                    }
                } catch (Throwable th2) {
                    try {
                        Logger.e("FileSizeUtil", "getFileSize Exception");
                        if (fileInputStream != null) {
                            try {
                                fileInputStream.close();
                            } catch (Exception e2) {
                                Logger.e("FileSizeUtil", "fis close error,ignore");
                            }
                        }
                        return j;
                    } catch (Throwable th3) {
                        th = th3;
                        if (fileInputStream != null) {
                            try {
                                fileInputStream.close();
                            } catch (Exception e3) {
                                Logger.e("FileSizeUtil", "fis close error,ignore");
                            }
                        }
                        throw th;
                    }
                }
            } catch (Throwable th4) {
                th = th4;
                fileInputStream = null;
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                throw th;
            }
        }
        return j;
    }

    private static long ॱ(File file) throws Exception {
        long j = 0;
        File[] listFiles = file.listFiles();
        if (listFiles != null) {
            for (int i = 0; i < listFiles.length; i++) {
                if (listFiles[i].isDirectory()) {
                    j += ॱ(listFiles[i]);
                } else {
                    j += ˊ(listFiles[i]);
                }
            }
        }
        return j;
    }

    private static double ˎ(long j, int i) {
        DecimalFormat decimalFormat = new DecimalFormat("#.0000");
        switch (i) {
            case 1:
                return Double.valueOf(decimalFormat.format((double) j)).doubleValue();
            case 2:
                return Double.valueOf(decimalFormat.format(((double) j) / 1024.0d)).doubleValue();
            case 3:
                return Double.valueOf(decimalFormat.format(((double) j) / 1048576.0d)).doubleValue();
            case 4:
                return Double.valueOf(decimalFormat.format(((double) j) / 1.073741824E9d)).doubleValue();
            default:
                return 0.0d;
        }
    }

    public static boolean ˊ(String str) {
        if (ˊ(str, 1) > 0.0d) {
            return true;
        }
        return false;
    }
}
